package com.jiangyg.devtools.toolkit.random;

import com.jiangyg.devtools.base.Creator;

import java.util.concurrent.ThreadLocalRandom;

/**
 * 类描述：中文名随机生成
 *
 * @author jiangyg
 * @date 2023-08-17
 */
public class ChineseNameCreator implements Creator<String> {

    private final String surname = "赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许何吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭";

    private final String username = "骏宇玄璀紫子全超益莉信美奎琪豪浩槐文巧治瑜雯诗涵曦嵘天誉喜伟嘉欣卿钰勇寅天宸兵祥运昊泽仁淳轩子泳瑶源杰正驿豪财熙海辉辉天华峻龙嘉诚嘉运财喜伟天俊熙熙利君帝云海伟熙霞艳宗书文国熙林天录熙明俊敬贵艺心艾悦思甜帅梅莲婷伯沁苹苗龙尔仕墨驿森桥丹东墨满阳骏鹏毓昆金宇宇木金豪天洋宇捷治智浩泽搏朗朗桐喜伊萱彤正裕馨湘锦湘玉元坤子侦山水茂阳海乐晨杰高启夫玉舟凌璇雨扬晨亭艳昊洋晴雨雨晨雨辰骞娴颖晞朝晓小蕾雯悦月秋绮书彤诗韬羿程惠忻";

    private final int surnameCount = surname.length();

    private final int usernameCount = username.length();

    @Override
    public String create() {
        final StringBuilder name = new StringBuilder();

        // 生成姓
        final int surnameidx = ThreadLocalRandom.current().nextInt(0, surnameCount);
        name.append(surname.charAt(surnameidx));

        // 生成名
        final int len = ThreadLocalRandom.current().nextInt(2, 3);
        for (int i = 0; i < len; i++) {
            final int usernameidx = ThreadLocalRandom.current().nextInt(0, usernameCount);
            name.append(username.charAt(usernameidx));
        }

        return name.toString();
    }

}
